import java.util.*;

class ThreeDLottery {
    private int[] winNumber;

    ThreeDLottery(int[] winNumber) {
        this.winNumber = winNumber;
    }

    public int[] getWinNumber() {
        return winNumber;
    }

    int getWins(int[] userNumber) {
        //在此实现彩票金额返回
        int winSum = 0;
        for (int k : winNumber) {
            winSum += k;
        }
        int userSum = 0;
        for (int j : userNumber) {
            userSum += j;
        }
        if (winSum == userSum) {
            if (winSum == 0 || winSum == 27) return 1040;
            else if (winSum == 1 || winSum == 26) return 345;
            else if (winSum == 2 || winSum == 25) return 172;
            else if (winSum == 3 || winSum == 24) return 104;
            else if (winSum == 4 || winSum == 23) return 69;
            else if (winSum == 5 || winSum == 22) return 49;
            else if (winSum == 6 || winSum == 21) return 37;
            else if (winSum == 7 || winSum == 20) return 29;
            else if (winSum == 8 || winSum == 19) return 23;
            else if (winSum == 9 || winSum == 18) return 19;
            else if (winSum == 10 || winSum == 17) return 16;
            else if (winSum == 11 || winSum == 16) return 15;
            else if (winSum == 12 || winSum == 15) return 15;
            else if (winSum == 13 || winSum == 14) return 14;
        }
        return 0;
    }
}

public class Main {
    public static void main(String[] arg) {
        Scanner sc = new Scanner(System.in);
        String winNumStr = sc.next(), userNumStr = sc.next();
        int[] winNum = new int[winNumStr.length()];
        for (int i = 0; i < winNumStr.length(); i++) {
            winNum[i] = Integer.parseInt(winNumStr.substring(i, i + 1));
        }
        int[] userNum = new int[userNumStr.length()];
        for (int i = 0; i < userNumStr.length(); i++) {
            userNum[i] = Integer.parseInt(userNumStr.substring(i, i + 1));
        }
        ThreeDLottery win = new ThreeDLottery(winNum);
        int wins = win.getWins(userNum);
        System.out.println(wins);

    }
}
